package com.itheima.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.bean.Student;
import com.itheima.mapper.StudentDao;
import com.itheima.service.StudentService;
import com.itheima.utils.MybatisUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class StudentServiceImpl implements StudentService {
    private SqlSession sqlSession = MybatisUtils.getSqlSession();
    private StudentDao studentDao = sqlSession.getMapper(StudentDao.class);

    /**
     * 分页查询
     * @param starePage
     * @param pageSize
     * @return
     */
    @Override
    public Page pageLimit(Integer starePage, Integer pageSize) {
        Page page = PageHelper.startPage(starePage, pageSize);
        studentDao.findAll();
        return page;


    }


    /**
     * 添加学生
     * @param student
     */
    @Override
    public void add(Student student) {
        studentDao.add(student);
    }


    /**
     * 修改学生
     * @param student
     */
    @Override
    public void update(Student student) {
        studentDao.update(student);
    }


    /**
     * 删除学生
     * @param number
     */
    @Override
    public void del(String number) {
        studentDao.del(number);
    }
}
